<template>
	<view>
		<view>{{ proname }}</view>
		<view>{{ originprice }}</view>
		<uni-goods-nav :fill="true"  :options="options" :buttonGroup="buttonGroup"  @click="onClick" @buttonClick="buttonClick" />
	</view>
</template>

<script>
	import { getProDetail } from '../../api/pro.js'
	import uniGoodsNav from '@/components/uni-goods-nav/uni-goods-nav.vue'
	export default {
		components: {
			uniGoodsNav
		},
		data() {
			return {
				proid: '',
				banners: [],
				proname: '',
				originprice: 0,
				discount: 0,
				options: [{
						icon: 'headphones',
						text: '客服'
					}, {
						icon: 'shop',
						text: '店铺',
						info: 2,
						infoBackgroundColor:'#007aff',
						infoColor:"red"
					}, {
						icon: 'cart',
						text: '购物车',
						info: 2
					}],
					buttonGroup: [{
					  text: '加入购物车',
					  backgroundColor: '#ff0000',
					  color: '#fff'
					},
					{
					  text: '立即购买',
					  backgroundColor: '#ffa200',
					  color: '#fff'
					}
				]
			  }
		},
		onLoad (options) {
			console.log('onLoad')
			console.log(options)
			this.proid = options.proid
		},
		mounted () {
			console.log('mounted')
			getProDetail(this.proid).then(res => {
				const banners = res.data.data.banners[0].split(',')
				this.banners = banners
				this.proname = res.data.data.proname
				this.originprice = res.data.data.originprice
				uni.setNavigationBarTitle({
					title: this.proname
				})
			})
		},
		methods: {
			onClick (e) {
				uni.showToast({
				  title: `点击${e.content.text}`,
				  icon: 'none'
				})
			  },
			  buttonClick (e) {
				console.log(e)
				this.options[2].info++
			  }
		}
	}
</script>

<style lang="stylus">

</style>
